home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / s / pagegenie.pgen < prev    next >
Text File  |  1992-03-14  |  18KB  |  889 lines

  1. /*
  2. @B@LPageGenie.pgen
  3. General purpose template filler
  4. This is the main engine of most PageGenies
  5. */
  6. parse arg sourcedir
  7. call pragma(d,"rexx:")
  8.  
  9. if ~show(l, "gdarexxsupport.library") then
  10.     if ~addlib("gdarexxsupport.library", 0, -30) then
  11.         exit_msg("Please install the gdarexxsupport.library in your libs: directory before running PageGenies!")
  12.  
  13. cr = '0a'x
  14. call SafeEndEdit.rexx()
  15. units = ppm_GetUnits()
  16. if units = 3 then
  17.     call ppm_SetUnits(1)
  18.  
  19. call SetClip(ppgenie_units, units)
  20.  
  21. signal on halt
  22. signal on break_c
  23. signal on break_e
  24. signal on break_d
  25.  
  26. functions = "EXECUTEGENIE INSERTPERSONALINFO IMPORTGRAPHIC SETTEXTSTYLE SETSIZE ENDEDITMODE LINKBOXES PROMPT UPDATESCREEN ZOOM REPLACETEXT JUSTIFY SELECTBOX LOADPAGE DONE MAKECOLUMNS ZOOM IMPORTTEXT SETFONT DELETEBOXCONTENTS"
  27.  
  28. functions = functions" EDITARTICLE REPLACESTRING GOTOPAGE"
  29.  
  30. list = getdirlist.rexx(sourcedir, "_pgtp") 
  31. if list = '' then exit_msg("Page Genies not installed properly. Please reninstall")
  32.  
  33. list = ppm_SelectFromList("Select type of Genie..", 30, 5, 0, list)
  34. if list = '' then exit_msg()
  35.  
  36. lastdir = ''
  37.  
  38. filename = sourcedir'/'list'_pgtp'
  39.  
  40. if ~open(file, filename, "r") then
  41.     exit_msg("An error has occured reading the PageGenie template file!")
  42.  
  43. /*    Initialize font list    */
  44. font = FontList.rexx()
  45. call ppm_SetBoxOutlines(1)
  46.  
  47. currentbox    = 0
  48. gutter        = .25
  49. cols        = 3
  50.  
  51. update = 1
  52.  
  53. if ppm_Inform(2, "Would you like to turn off the auto update to speed up screen refresh? Some text updates may appear to lag a step behind.", "No", "Yes") then
  54. do
  55.     call ppm_AutoUpdate(0)
  56.     update = 0
  57. end
  58.  
  59. do while ~eof(file)
  60.  
  61.     line = readln(file)
  62.  
  63.     parse var line command ';' .
  64.     command = strip(upper(command))
  65.  
  66.     if pos(command, functions) ~= 0 then
  67.         interpret "call "command"(line)"
  68.     else if line ~= '' & pos('/*', line) = 0 & pos('*/', line) = 0 then
  69.         call ppm_Inform(1,"Could not understand line: "line,)
  70.  
  71. end
  72.  
  73. exit_msg("")
  74.  
  75. EXECUTEGENIE: procedure expose sourcedir units
  76. do
  77.     parse arg line
  78.     parse var line command ';' geniename ';' extension
  79.  
  80.     if pos(".pgen", geniename) ~= 0 then
  81.     do
  82.         pgen = 1
  83.         root = sourcedir'/'
  84.     end
  85.     else root = ''
  86.  
  87.  
  88.     if geniename = '' then
  89.     do
  90.         list = getdirlist.rexx(sourcedir, extension)
  91.         if list = '' then return
  92.  
  93.         geniename = ppm_SelectFromList("Select a Genie..", 30, 5, 0, list)
  94.         if geniename = '' then return
  95.  
  96.         geniename = geniename||extension
  97.  
  98.     end
  99.  
  100.     if ~exists(root||geniename) then
  101.     do
  102.         call ppm_Inform(1,"Unable to locate Genie: "geniename,)
  103.         return
  104.     end
  105.  
  106.     if pgen = 1 then
  107.         currdir = pragma('d', sourcedir)
  108.     else
  109.     do
  110.         currdir = pragma('d', splitroot(geniename))
  111.         geniename = '"'splitpath(geniename)'"'
  112.     end
  113.  
  114.     address command
  115.  
  116.     if pgen = 1 then
  117.         interpret "call "'"'geniename'"'"(sourcedir)"
  118.     else
  119.         interpret "call "geniename"()"
  120.  
  121.     call pragma('d', currdir)
  122.     call ppm_SetUnits(1)
  123.     return
  124.  
  125. end
  126.  
  127. ZOOM:    procedure expose units
  128. do
  129.     parse arg line
  130.     parse var line command ';' percentage 
  131.  
  132.     if ~datatype(percentage, n) then return
  133.  
  134.     call SafeEndEdit.rexx()
  135.  
  136.     call ppm_ShowStatus("Zooming to %"percentage)
  137.     call ppm_SetMagMode(percentage)
  138.     call ppm_UpdateScreen()
  139.     return
  140. end
  141.  
  142. DONE: procedure expose units
  143. do
  144.  
  145.     parse arg line
  146.     parse var line command ';'    message ';' boxes
  147.  
  148.     call SafeEndEdit.rexx()
  149.     pages = 0
  150.  
  151.     do while boxes ~= ''
  152.  
  153.         parse var boxes boxname ';' boxes
  154.  
  155.         if boxname = '' then iterate
  156.         if boxname = 'PAGENAMES' then pages = 1
  157.  
  158.         if pages then
  159.         do
  160.             page = ppm_PageNum(boxname)
  161.             if page ~= 0 then call ppm_SetPageName(page, "")
  162.         end
  163.         else
  164.         do
  165.             box = ppm_BoxNum(boxname)
  166.             if box ~= 0 then call ppm_SetBoxName(box, "")
  167.         end
  168.  
  169.     end
  170.  
  171.     call exit_msg(message)
  172.  
  173. end
  174.  
  175. LOADPAGE: procedure expose sourcedir units
  176. do
  177.  
  178.     parse arg line
  179.     parse var line command ';' pagename ';' extension
  180.  
  181.  
  182.     call SafeEndEdit.rexx()
  183.  
  184.     if strip(pagename) = '' then
  185.     do
  186.         list = getdirlist.rexx(sourcedir, extension)
  187.         if list = '' then
  188.             abort("Unable to open appropriate templates")
  189.  
  190.         do forever
  191.  
  192.             pagename = ppm_SelectFromList("Select template..", 30, 5, 0, list)
  193.             if pagename = '' then abort()
  194.  
  195.             pagename = sourcedir'/'pagename||extension
  196.  
  197.             if ~ppm_LoadPage(ppm_CurrentPage() + 1, pagename, 1) then
  198.                 abort("An error has occured loading page:" pagename)
  199.  
  200.             call ppm_UpdateScreen()
  201.  
  202.             resp = ppm_Inform(3,"Use this template?", "Abort Genie","Try Another", "Yes") 
  203.  
  204.             if resp = 0 then abort("Genie Aborted!")
  205.             else if resp = 2 then return
  206.  
  207.             call ppm_DeletePage(ppm_CurrentPage(),1)
  208.  
  209.         end
  210.  
  211.     end
  212.     else
  213.     do
  214.         /*    look for pagename in current directory, if we cant find it
  215.          *    assume its in the source directory
  216.          */
  217.         if ~exists(pagename) then
  218.             pagename = sourcedir'/'pagename
  219.  
  220.         if ~exists(pagename) then
  221.             abort("Unable to open appropriate templates")
  222.     end
  223.  
  224.     call ppm_Showstatus("Attempting to load page: "pagename)
  225.  
  226.     if ~ppm_LoadPage(ppm_CurrentPage() + 1, pagename, 1) then
  227.         abort("An error has occured loading page:" pagename)
  228.  
  229.     call ppm_UpdateScreen()
  230.  
  231.     return
  232. end
  233.  
  234. SELECTBOX: procedure expose currentbox update units
  235. do
  236.     parse arg line
  237.     parse var line command ';' boxname ';' edit
  238.  
  239.     call SafeEndEdit.rexx()
  240.  
  241.     box = ppm_BoxNum(boxname)
  242.  
  243.     if box = 0 then
  244.     do
  245.         if ~ppm_Inform(2, "Unable to find a box in current template. This Page Genie may not function properly. Continue?", "No", "Yes") then
  246.             abort()
  247.         else
  248.             return
  249.     end
  250.  
  251.  
  252.     boxpos    = ppm_GetBoxPosition(box)
  253.     call ppm_SetPagePosition(word(boxpos, 1), word(boxpos, 2))
  254.  
  255.     if edit = 1 then call SafeSetEdit.rexx(box)
  256.     currentbox = box
  257.  
  258.     bpage    = ppm_BoxPage(box)
  259.     
  260.     if bpage ~= ppm_CurrentPage() then 
  261.     do
  262.         call ppm_GotoPage(bpage)
  263.  
  264.         if update then
  265.             call ppm_UpdateScreen()
  266.     end
  267.  
  268.     return
  269.  
  270. end
  271.  
  272. REPLACETEXT: procedure expose currentbox update units
  273. do
  274.     parse arg line
  275.     parse var line command ';' insert ';' prompt ';' prompt2
  276.  
  277.     if currentbox = 0 then return
  278.     
  279.     call SafeEndEdit.rexx()
  280.     info = upper(word(ppm_GetBoxInfo(currentbox), 1))
  281.     if info ~= "TEXT" & info ~= "EMPTY" then return
  282.  
  283.     do forever
  284.  
  285.         typo = ppm_GetBoxText(currentbox, 0)
  286.  
  287.         if typo ~= '' then
  288.             typo = left(typo, skipcodes(typo, 1) - 1)
  289.  
  290.         if insert = 1 then
  291.         do
  292.             text = left(ppm_GetBoxText(currentbox,0), 50)
  293.             cr     = pos('0a'x, text)
  294.             if cr ~= 0 then text = left(text, max(1, cr - 1))
  295.             text = strip(text)
  296.         end
  297.         else
  298.             text = ''
  299.  
  300.         rtext    = ppm_GetForm(prompt, 40, prompt":"text)
  301.         if rtext = '' then return
  302.  
  303.         call ppm_DeleteContents(currentbox)
  304.         call ppm_TextIntoBox(currentbox, rtext)
  305.  
  306.         if SETTEXTSTYLE(1) = 2 then return
  307.         call SafeEndEdit.rexx()
  308.         insert = 1
  309.  
  310.     end
  311.  
  312. end
  313.  
  314. SETSIZE: procedure expose currentbox units
  315. do
  316.     parse arg line
  317.     parse var line command 
  318.  
  319.     if currentbox = 0 then return
  320.  
  321.     if ppm_GetState() ~= "3 99" then 
  322.         call SafeSetEdit.rexx(currentbox)
  323.  
  324.     call ppm_SelectAllText()
  325.  
  326.     do forever
  327.  
  328.         size = ppm_GetSize()
  329.         size = ppm_Getform("Set font size..", 8, "Size:"size)
  330.         if size = '' then leave
  331.  
  332.         if ~datatype(size, n) then
  333.         do
  334.             call PromptUser("Invalid entry")
  335.             iterate
  336.         end
  337.  
  338.         call ppm_SetSize(size)
  339.  
  340.         if ~ppm_TextOverflow() then leave
  341.  
  342.         if ppm_Inform(2, "Is this OK?", "Try Again", "Yes") then
  343.             leave
  344.  
  345.     end
  346.  
  347.     return
  348.  
  349. end
  350.  
  351. SETFONT: procedure expose currentbox  units
  352. do
  353.     parse arg line
  354.     parse var line command 
  355.  
  356.     if currentbox = 0 then return
  357.  
  358.     if ppm_GetState() ~= "3 99" then
  359.         call SafeSetEdit.rexx(currentbox)
  360.  
  361.     call ppm_SelectAllText()
  362.  
  363.     do forever
  364.  
  365.         font = ppm_GetFont()
  366.         font = ppm_SelectFromList("Select Font..", 30, 10, 0, FontList.rexx(font))
  367.         if font = '' then leave
  368.  
  369.         call ppm_SetFont(font)
  370.  
  371.         if ppm_Inform(2, "Is this OK?", "Try Again", "Yes") then
  372.             leave
  373.  
  374.     end
  375.  
  376.     return
  377.  
  378. end
  379.  
  380.  
  381. JUSTIFY: procedure expose currentbox units
  382. do
  383.     parse arg line
  384.     parse var line command ';' justification
  385.  
  386.     if currentbox = 0 then return
  387.  
  388.     if ppm_GetState() ~= "3 99" then
  389.         call SafeSetEdit.rexx(currentbox)
  390.  
  391.     call ppm_SelectAllText()
  392.     if ~datatype(justification, n) then return
  393.  
  394.     call ppm_SetJustification(justification)
  395.  
  396.     return
  397.  
  398. end
  399.  
  400. MAKECOLUMNS: procedure expose currentbox gutter cols units
  401. do
  402.     cr = '0a'x
  403.  
  404.     if currentbox = 0 then return
  405.     call SafeEndEdit.rexx()
  406.  
  407.     if units = 3 then gutter = ppm_ConvertUnits(1, 3, gutter)
  408.  
  409.     do forever
  410.  
  411.         user = ppm_GetForm("How many colums will you need?", 8, "Columns 1 - 6:"cols||cr"Gutter:"gutter)
  412.         if user = '' then return
  413.  
  414.         parse var user cols '0a'x gutter
  415.  
  416.         if ~(datatype(cols, n)  & datatype(gutter, n)) | cols > 6  | cols < 1 then 
  417.         do
  418.             call PromptUser("Invalid Entry")
  419.             iterate
  420.         end
  421.  
  422.         break
  423.     end
  424.  
  425.  
  426.     if units = 3 then gutter = ppm_ConvertUnits(3, 1, gutter)
  427.  
  428.     list = ppm_SelectFromList("Select column options..", 30, 2,1, "Vertical Dividers"cr"Borders")
  429.  
  430.     if pos('Vertical', list) ~= 0 then 
  431.         vert = y
  432.     else
  433.         vert = n
  434.  
  435.     if pos('Borders', list) ~= 0 then 
  436.         borders = y
  437.     else 
  438.         borders = n
  439.  
  440.     name = ppm_GetBoxName(currentbox)
  441.     box = MakeBoxIntoColumns.pprx(currentbox, cols, gutter, vert, borders, "Y")
  442.  
  443.     call ppm_SetBoxName(box, name)
  444.     currentbox = box
  445.     return
  446.  
  447. end
  448.  
  449. IMPORTTEXT: procedure expose currentbox update lastdir units
  450. do
  451.     if currentbox = 0 then return
  452.  
  453.     call SafeEndEdit.rexx()
  454.     info = upper(word(ppm_GetBoxInfo(currentbox), 1))
  455.     if info ~= "TEXT" & info ~= "EMPTY" then return
  456.     
  457.     typo = ppm_GetBoxText(currentbox, 0)
  458.  
  459.     if typo ~= '' then
  460.         typo = left(typo, skipcodes(typo, 1) - 1)
  461.  
  462.  
  463.     do forever
  464.  
  465.         call SafeEndEdit.rexx()
  466.  
  467.         if ppm_Inform(2, "Import a text file?", "No", "Yes") then
  468.         do
  469.             filename = ppm_GetFileName("Select Text File..", lastdir, "")
  470.             if filename = '' then return
  471.             lastdir = splitroot(filename)
  472.                 
  473.             call ppm_ShowStatus("Attempting to import "filename)
  474.  
  475.             call ppm_DeleteContents(currentbox)
  476.             call ppm_TextIntoBox(currentbox, typo)
  477.  
  478.             if ~ppm_ImportText(ppm_ArtFirstBox(currentbox),filename) then
  479.             do
  480.                 call ppm_Inform(1, "Unable to import "filename,)
  481.                 return
  482.             end
  483.  
  484.             if SETTEXTSTYLE(1) = 2 then return
  485.             call SafeEndEdit.rexx()
  486.  
  487.         end
  488.         else
  489.             return
  490.     end
  491.  
  492. end
  493.  
  494. UPDATESCREEN: procedure expose units
  495. do
  496.  
  497.     call SafeEndEdit.rexx()
  498.  
  499.     call ppm_UpdateScreen()
  500.     return
  501. end
  502.  
  503. PROMPT:    procedure expose units
  504. do
  505.     parse arg line
  506.     parse var line command ';' string
  507.  
  508.     if string ~= '' then 
  509.     do
  510.         if length(string) > 1000 then
  511.         do
  512.             zbox =  ppm_CreateBox(-2, -2, .001, .001, 0)
  513.             call SafeSetEdit.rexx(zbox)
  514.             call ppm_InsertText(string)
  515.             call ppm_EditWithAE()
  516.             call SafeEndEdit.rexx()
  517.             call ppm_DeleteContents(zbox)
  518.         end
  519.         else
  520.             call ppm_Inform(1,string,)
  521.     end
  522.  
  523.     return
  524. end
  525.  
  526. break_d:
  527. break_e:
  528. break_c:
  529. halt:
  530.     call abort("User aborted Genie!")
  531.  
  532. exit_msg: procedure expose units
  533. do
  534.     parse arg message
  535.     call SafeEndEdit.rexx()
  536.  
  537.     if message ~= '' then call ppm_Inform(1,message,)
  538.  
  539.     call ppm_AutoUpdate(1)
  540.     call ppm_SetUnits(units)
  541.     call ppm_ClearStatus()
  542.     exit
  543. end
  544.  
  545. LINKBOXES: procedure expose currentbox units
  546. do
  547.     parse arg line
  548.     parse var line command ';' box1 ';' box2
  549.  
  550.     call SafeEndEdit.rexx()
  551.  
  552.     if box1 = '' | box2 = '' then return
  553.  
  554.     boxnum1 = ppm_BoxNum(box1)
  555.     boxnum2 = ppm_BoxNum(box2)
  556.     
  557.     info1 = upper(word(ppm_GetBoxInfo(boxnum1), 1))
  558.     info2 = upper(word(ppm_GetBoxInfo(boxnum2), 1))
  559.  
  560.     if verify(info1, "EMPTYTEXT") ~= 0 then return
  561.  
  562.     call ppm_DeleteContents(boxnum2)
  563.     call ppm_ShowStatus("Linking boxes..")
  564.  
  565.     if boxnum1 ~= 0 & boxnum2 ~= 0 then
  566.         call ppm_LinkBox(ppm_ArtLastBox(box1), box2)
  567.  
  568.     return
  569.  
  570. end
  571.  
  572. ENDEDITMODE: procedure expose units
  573. do
  574.     call SafeEndEdit.rexx()
  575.     return
  576. end
  577.  
  578. IMPORTGRAPHIC: procedure expose currentbox lastdir units
  579. do
  580.  
  581.     cr = '0a'x
  582.  
  583.     if currentbox = 0 then return
  584.     call SafeEndEdit.rexx()
  585.  
  586.  
  587.     list = ppm_SelectFromList("Select type of graphic to import..", 30, 5, 0, "BitMap"cr"ProDraw Clip"cr"Aegis Draw"cr"EPSF")
  588.     if list = '' then return
  589.  
  590.  
  591.     do forever
  592.  
  593.         call ppm_DeleteContents(currentbox)
  594.  
  595.         if list = 'ProDraw Clip' then
  596.             res = ppm_ImportClip(currentbox,"","") 
  597.         else
  598.         do
  599.  
  600.             graphic = ppm_GetFileName("Please Select a "list" graphic", lastdir, "")
  601.             if graphic = '' then return
  602.             lastdir = splitroot(graphic)
  603.  
  604.             if list = 'Aegis Draw' then
  605.                 res = ppm_ImportAegis(currentbox, graphic) 
  606.             else if list = 'BitMap' then
  607.                 res = ppm_ImportBM(currentbox, graphic)
  608.             else if list = 'EPSF' then
  609.                 res = ppm_ImportEPSF(currentbox, graphic)
  610.                 
  611.         end
  612.  
  613.         if res = 0 then
  614.         do
  615.             if ~ppm_Inform(2,"Unable to load file. Try again?", "No", "Yes") then return
  616.         end
  617.         else
  618.             return
  619.  
  620.     end
  621.  
  622. end
  623.  
  624. INSERTPERSONALINFO: procedure expose currentbox update units
  625. do
  626.  
  627.     if currentbox = 0 then return
  628.     call SafeEndEdit.rexx()
  629.     info = upper(word(ppm_GetBoxInfo(currentbox), 1))
  630.     if info ~= "TEXT" & info ~= "EMPTY" then return
  631.  
  632.     call SafeSetEdit.rexx(currentbox)
  633.  
  634.     if ~ppm_Inform(2,"Would you like to insert your Personal info?", "No","Yes") then
  635.         return
  636.  
  637.     call InsertPersonalInfo.pprx()
  638.     call SETTEXTSTYLE(0) 
  639.     return
  640.  
  641. end
  642.  
  643.  
  644. SETTEXTSTYLE: procedure expose currentbox update units
  645. do
  646.  
  647.     parse arg earlyreturn
  648.  
  649.     if currentbox = 0 then return
  650.     cr = '0a'x
  651.  
  652.     call SafeEndEdit.rexx()
  653.     info = upper(word(ppm_GetBoxInfo(currentbox), 1))
  654.     if info ~= "TEXT" & info ~= "EMPTY" then return
  655.  
  656.     do forever
  657.  
  658.         call SafeSetEdit.rexx(currentbox)
  659.         call ppm_SelectAllText()
  660.  
  661.         size = ppm_GetSize()
  662.         size = ppm_GetForm("Select font size..", 8, "Size:"size)
  663.         
  664.  
  665.         if datatype(size, n) then
  666.         do
  667.             call ppm_ShowStatus("Setting text size..")
  668.             call ppm_SetSize(size)
  669.  
  670.             if update then
  671.             do
  672.                 call SafeEndEdit.rexx()
  673.                 call SafeSetEdit.rexx(currentbox)
  674.                 call ppm_SelectAllText()
  675.             end
  676.         end
  677.         else if size ~= '' then
  678.         do
  679.             call PromptUser("Invalid Entry")
  680.             iterate
  681.         end
  682.  
  683.         font = ppm_SelectFromList("Select font..", 30, 10, 0, FontList.rexx(ppm_GetFont()))
  684.         if font ~= '' then 
  685.         do
  686.             call ppm_SetFont(font)
  687.  
  688.             if update then
  689.             do
  690.                 call SafeEndEdit.rexx()
  691.                 call SafeSetEdit.rexx(currentbox)
  692.                 call ppm_SelectAllText()
  693.             end
  694.         end
  695.  
  696.         style = ppm_GetStyle()
  697.         if pos("B", style) ~= 0 then style = "Bold"
  698.         else if pos("B", style) ~= 0 then style = "Bold"
  699.         else if pos("N", style) ~= 0 then style = "Plain"
  700.         else if pos("U", style) ~= 0 then style = "Underline"
  701.         else if pos("I", style) ~= 0 then style = "Italic"
  702.         else if pos("O", style) ~= 0 then style = "Outline"
  703.  
  704.         style = ppm_SelectFromList("Select Style..", 25, 4, 1, ItemToFront.rexx(style,"Plain"cr"Italic"cr"Outline"cr"Bold"cr"Underline"))
  705.  
  706.  
  707.         tstyle = ''
  708.  
  709.         if pos("Bold", style) ~= 0 then tstyle = 'b'
  710.         if pos("Italic", style) ~= 0 then tstyle = tstyle'i'
  711.         if pos("Underline", style) ~= 0 then tstyle = tstyle'u'
  712.         if pos("Outline", style) ~= 0 then tstyle = tstyle'o'
  713.         if pos("Plain", style) ~= 0 then tstyle = 'n'
  714.  
  715.         if tstyle ~= '' then
  716.         do
  717.             call ppm_ShowStatus("Setting text style..")
  718.             call ppm_SetStyle(tstyle)
  719.             
  720.             if update then
  721.             do
  722.                 call SafeEndEdit.rexx()
  723.                 call SafeSetEdit.rexx(currentbox)
  724.                 call ppm_SelectAllText()
  725.             end
  726.         end
  727.         
  728.         justify = ppm_GetJustification()
  729.         if justify = 0 then justify = "Left"
  730.         else if justify = 1 then justify = "Right"
  731.         else if justify = 2 then justify = "Center"
  732.         else if justify = 3 then justify = "Flush"
  733.  
  734.         justify = ppm_SelectFromList("Select justification..", 25, 4, 0, ItemToFront.rexx(justify,"Left"cr"Center"cr"Right"cr"Flush"))
  735.         
  736.         if justify ~= '' then
  737.         do
  738.  
  739.             call ppm_ShowStatus("Setting text justification..")
  740.  
  741.             if justify = "Left" then call ppm_SetJustification(0)
  742.             if justify = "Right" then call ppm_SetJustification(1)
  743.             if justify = "Center" then call ppm_SetJustification(2)
  744.             if justify = "Flush" then call ppm_SetJustification(3)
  745.  
  746.             if update then
  747.             do
  748.                 call SafeEndEdit.rexx()
  749.                 call SafeSetEdit.rexx(currentbox)
  750.                 call ppm_SelectAllText()
  751.             end
  752.         end
  753.         
  754.         resp = ppm_Inform(3, "Is this OK?", "Abort Genie", "Try Again", "Yes") 
  755.         if resp = 0 then call abort()
  756.  
  757.         if earlyreturn = 1 then return(resp)
  758.  
  759.         if resp = 2 then return
  760.  
  761.     end
  762.  
  763. end
  764.  
  765. DELETEBOXCONTENTS: procedure expose currentbox units
  766. do
  767.  
  768.     if currentbox = 0 then return
  769.  
  770.     call SafeEndEdit.rexx()
  771.  
  772.     call ppm_DeleteContents(currentbox)
  773.     return
  774.  
  775. end
  776.  
  777. EDITARTICLE: procedure expose currentbox units
  778. do
  779.  
  780.     if currentbox = 0 then return
  781.  
  782.     call SafeEndEdit.rexx()
  783.     info = upper(word(ppm_GetBoxInfo(currentbox), 1))
  784.  
  785.     if info ~= TEXT & info ~= "EMPTY" then return
  786.  
  787.     if ppm_GetState() ~= "3 99" then call SafeSetEdit.rexx(currentbox)
  788.     call ppm_EditWithAE()
  789.  
  790.     return
  791. end
  792.  
  793. REPLACESTRING: procedure expose currentbox  units
  794. do
  795.     parse arg line
  796.     parse var line command ';' searchstring ';' case
  797.  
  798.     if currentbox = 0 then return
  799.     if searchstring = '' then return
  800.  
  801.     call SafeEndEdit.rexx()
  802.     info = upper(word(ppm_GetBoxInfo(currentbox), 1))
  803.     if info ~= "TEXT" & info ~= "EMPTY" then return
  804.  
  805.     if ppm_GetState() ~= "3 99" then call SafeSetEdit.rexx(currentbox)
  806.  
  807.     if ~datatype(case, n) | verify(case, "01") ~= 0 then case = 1
  808.  
  809.     if ~ppm_Find(searchstring, 0, case) then return
  810.  
  811.     repstring =ppm_GetForm("Enter replacement string..", 30,"String:"searchstring)
  812.     call ppm_InsertText(repstring)
  813.  
  814.     return
  815.  
  816. end
  817.  
  818. PromptUser:
  819. do
  820.     parse arg message
  821.  
  822.     call ppm_Inform(1, message,)
  823.     return
  824. end
  825.  
  826. GOTOPAGE: procedure expose units
  827. do
  828.     parse arg line
  829.     parse var line command ';' page
  830.  
  831.     cpage = ppm_PageNum(page)
  832.  
  833.     if cpage = 0 then
  834.     do
  835.         call Prompt("Unable to identify page named: "page". Genie may not function properly.")
  836.         return
  837.     end
  838.  
  839.     call ppm_ShowStatus("Going to page named "page)
  840.     call ppm_GotoPage(cpage)
  841.     return
  842. end
  843.  
  844.  
  845. splitpath: procedure expose units
  846. do
  847.     parse arg path
  848.  
  849.     colon = lastpos('/', path)
  850.     if colon = 0 then colon = lastpos(':', path)
  851.  
  852.     if colon = 0 then return(path)
  853.     else return(substr(path, colon + 1))
  854. end
  855.  
  856. splitroot: procedure expose units
  857. do
  858.     parse arg root
  859.  
  860.     colon = lastpos('/', root)
  861.     if colon = 0 then colon = pos(':', root)
  862.  
  863.  
  864.     if colon = 0 then return("")
  865.     else return(left(root, colon))
  866. end
  867.  
  868. abort: procedure expose file units
  869. do
  870.  
  871.     parse arg message
  872.  
  873.     if message ~= '' then call ppm_Inform(1,message,)
  874.  
  875.     do while ~eof(file)
  876.  
  877.         line = readln(file)
  878.  
  879.         parse var line command ';' .
  880.         command = strip(upper(command))
  881.  
  882.         if command = "DONE" then call DONE(line)
  883.  
  884.     end
  885.  
  886.     exit_msg("Done")
  887. end
  888.  
  889.